home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
076-100
/
disk_079
/
sharedlib
/
protect.i.orig
< prev
next >
Wrap
Text File
|
1992-05-06
|
1KB
|
53 lines
;; Protect.i Copyright 1987 by James M Synge
;;
;; An assembly macro for protecting registers.
;; Not for the weak of heart.
macro protect
if NARG <> 2
fail ; Must specify the number of args!
mexit
endc
iflt \2
fail ; Negative number of args!
mexit
endc
; Until a bug fix arrives for the assembler so that the \0
; macro works, we must assume the argument size is 4 bytes.
\@elementsize set 4
\@bytes set \@elementsize * \2
\@offset set \@bytes + (AztecBugSize * 4)
movem.l AztecBugList,-(sp) ; Save some regs
; Push the argument(s). We'll use D0 as our scratch
; register since it is free for that use according
; to the register convention.
ifne \2 ; If there are any arguments
moveq #\2,d0 ; Number of arguments to move
\@loop move.l \@offset(sp),-(sp) ; Push an arg
dbeq d0,\@loop ; Loop again?
endc
jsr \1 ; Call the C routine
ifne \2 ; Pop any arguments
ifge 8 - \@bytes ; Can we use addq.l?
addq.l #\@bytes,sp ; Yup!
else
lea \@bytes(sp),sp ; Otherwise use lea
endc
endc
movem.l (sp)+,AztecBugList ; Restore regs
rts ; And return
endm ; End of the protect macro